package com.eascs.admin.o2o.compensatory.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eascs.admin.o2o.compensatory.dao.O2oDCLoanDao;
import com.eascs.admin.o2o.compensatory.entity.CompensatoryDataEnter;
import com.eascs.admin.o2o.compensatory.entity.DCUpdateData;
import com.eascs.admin.o2o.compensatory.entity.DCUpdateNumVo;
import com.eascs.admin.o2o.compensatory.entity.O2oDCLoanVo;
import com.eascs.admin.o2o.loan.entity.O2oEaLoanDataEnity;
import com.eascs.app.dao.PageResult;

@Service
public class O2oDCLoanService {

	@Autowired
	O2oDCLoanDao dcLoanDao;
	
	public O2oEaLoanDataEnity findEaLoanData(String billCode){
		return dcLoanDao.findEaLoanData(billCode);
	}
	
	//查询代偿数据
	public PageResult<Object[]> getDCByPage(O2oDCLoanVo vo){
		return dcLoanDao.getDCByPage(vo);
	}
	
	//查询代偿资料录入表
	public CompensatoryDataEnter findloanDataIdById(String id){
		return dcLoanDao.findloanDataIdById(id);
	}
	
	//保存代偿录入资料
	@Transactional("o2oTransactionManager")
	public int saveEnterInfo(CompensatoryDataEnter entity){
		O2oEaLoanDataEnity loanDataEntity=dcLoanDao.getById(O2oEaLoanDataEnity.class, entity.getLoanDataId());
		loanDataEntity.setStatus("CLO");
		dcLoanDao.updateById(loanDataEntity);
		return dcLoanDao.saveEnterInfo(entity);
	}
	
	//根据id查询billcode
	public String findBillCodeById(String loanDataId){
		return dcLoanDao.findBillCodeById(loanDataId);
	}
	
	//修改代偿录入资料
	public int updateEnterInfo(CompensatoryDataEnter vo){
		return dcLoanDao.updateEnterInfo(vo);
	}
	
	//根据id修改剩余量
	public int addResidueNum(DCUpdateNumVo vo) {
		return dcLoanDao.addResidueNum(vo);
	}
	
	//根据id查询省份
	public String findProvinceById(String loanDataId){
		return dcLoanDao.findProvinceById(loanDataId);
	}
	
	//根据省份查询省份简称
	public String findJCByProvince(String province) {
		return dcLoanDao.findJCByProvince(province);
	}
	
	//根据billcode查询代偿数据
	public CompensatoryDataEnter findByBillCode(String billcode){
		return dcLoanDao.findByBillCode(billcode);
	}
	
	//修改借出和剩余数量
	public int updateLandRDate(DCUpdateData vo){
		return dcLoanDao.updateLandRDate(vo);
	}
	
	/*//借出修改
	public int updateLend(DCUpdateNumVo vo) {
		return dcLoanDao.updateLend(vo);
	}
		
	//归还修改
	public int updateGiveBack(DCUpdateNumVo vo) {
		return dcLoanDao.updateGiveBack(vo);
	}*/
}
